package com.yzd.learnjava.containers;

import java.util.PriorityQueue;

import com.yzd.learnjava.util.Print;

public class ToDoList extends PriorityQueue<ToDoList.ToDoItem> {
	static class ToDoItem implements Comparable<ToDoItem>{
		private char primary;
		private int secondary;
		private String item;
		public ToDoItem(String td , char pri , int sec) {
			this.primary = pri;
			this.secondary = sec;
			this.item = td;
		}
		
		public int compareTo(ToDoItem arg) {
			if(primary > arg.primary) {
				return +1;
			} 
			if(primary == arg.primary) {
				if(secondary > arg.secondary) {
					return +1 ;
				} else if(secondary == arg.secondary) {
					return 0;
				}
			}
			return -1;
		}
		
		public String toString() {
			return Character.toString(primary) + secondary + " : " + item;
		}
	}
	
	public void add(String td,  char pri , int sec) {
		super.add(new ToDoItem(td, pri, sec));
	}
	
	public static void main(String[] args) {
		ToDoList toDoList = new ToDoList();
		toDoList.add("Empty trash", 'C', 4);
		toDoList.add("Feed Dog", 'A', 2);
		toDoList.add("Feed Bird", 'B', 7);
		toDoList.add("Mow lawn", 'C', 3);
		toDoList.add("Feed Cat", 'B', 1);
		toDoList.add("Water lawn", 'A', 1);
		
		while(!toDoList.isEmpty()) {
			Print.print(toDoList.remove());
		}
	}
}























